#pragma once
#include "Singleton.h"
#include "ObjectFactory.h"

class CShapeInfo;
class GEOMDBAPI CShapeInfoCreator
{
public:
	virtual CShapeInfo* Create(void) = 0;
};

//////////////////////////////////////////////////////////////////////////
class GEOMDBAPI CShapeInfoFactory
	: public ATools::TSingleton<CShapeInfoFactory>,
	public ATools::TObjectFactory<CShapeInfo, CString, CShapeInfoCreator>
{
public:
	CShapeInfoFactory(void);
	~CShapeInfoFactory(void);
	void Initialize(void);
	CShapeInfo* Create(const CString& szId);
};

inline CShapeInfoFactory& GetShapeInfoFactory()
{
	return CShapeInfoFactory::Instance();
}

//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CRegShapeInfoHelper
{
public:
	CRegShapeInfoHelper(const CString& guid, CShapeInfoCreator* pEditorCreator);
	~CRegShapeInfoHelper();
protected:
	void Register(CShapeInfoCreator* pCreator);
	const CString& m_Guid;
};

#define REGISTERE_SHAPEINFO(ShapeInfo, Id) \
	static CRegShapeInfoHelper s_regHelper##Editor(Id,\
	new ATools::TObjectCreator<ShapeInfo, CShapeInfoCreator>());


